home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvtools
/
demos
/
mfgdemo
/
mfg_main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-07-10
|
5KB
|
210 lines
#ifndef lint
static char SccsId[]= "@(#)mfg_main.c V1.10 3/15/95";
#endif
/*------------------------------------------------------------------
| file name -- main.c
|-----------------------------------------------------------------*/
#include "std.h"
#include "dvstd.h"
#include "dvtools.h"
#include "Tfundecl.h"
#include "mfg_vars.h"
#include "VOfundecl.h"
#include "VUerfundecl.h"
#include "GRfundecl.h"
#include "mfg_fundecl.h"
#include "MISCfuns.h"
#ifdef WINNT
#include <windows.h>
#endif /* WINNT */
/* This program can be linked to run:
|
| With 100% CPU usage (which shows updates in a tight loop)
| comment #define DV_USE_TIMER
| With Time-Outs (which show update based on a timer.
| uncomment #define DV_USE_TIMER
*/
#define DV_USE_TIMER
#ifdef DV_USE_TIMER
LOCAL INT interval = 200;
long updating=0; /* prevent timer from updating screen too often */
#ifdef WINNT
LOCAL HWND Hwnd;
LOCAL VOID CALLBACK TimeOutProc V_P_((HWND hwnd,
UINT uMsg,
UINT idEvent,
DWORD dwTime));
#else /* UNIX */
#ifdef CONST
#undef CONST
#endif
#ifndef __STDC__
#define _NO_PROTO
#endif
/* X11 include files */
#include <X11/Xlib.h>
#include <X11/Intrinsic.h>
LOCAL XtAppContext app_context;
/***************** Begin Function Declarations *************/
LOCAL void time_out_proc V_P_((ADDRESS args, XtIntervalId *interval_id));
/***************** End Function Declarations *************/
#endif /* Not WINNT */
#endif /* DV_USE_TIMER */
#define SEARCH_PATH (CHAR*)NULL
#define DISPFORM_TABLE (CHAR*)NULL
/*---------------------------------------------------------------------
| main()
| This module is the basic skeleton of a DataViews application.
|
*/
#ifdef WINNT
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
CHAR *device = "W:=600x480";//NULL;
OBJECT location;
INT argc = 0;
CHAR **argv;
make_argv(&argc,&argv,GetCommandLine());
#else /* Not WINNT */
int
main (argc, argv)
int argc;
char *argv[];
{
CHAR *device = NULL;
OBJECT location;
#endif /* WINNT */
/* Initialize Arguments, argv[1] - display device (default is DVDEVICE) */
if (argc > 1)
device = argv[1];
/* Initialize */
/* DataViews Initializaton */
(VOID) TInit (SEARCH_PATH, DISPFORM_TABLE);
location = VOloCreate ();
InitDataTable (); /* found in mfg_rebind.c */
InitDisplays (device); /* found in mfg_dsp.c */
#ifdef DV_USE_TIMER
#ifdef WINNT
/* Get the Windows based information */
(VOID) GRget (V_WIN32_WINDOW_HANDLE, &Hwnd, V_END_OF_LIST);
/* Post a timeout for dynamic updates
| The timeout procedure will update the dynamics of
| all screens which have been opened. The procedure is invoked
| whenever the specified time interval elapses. The interval is
| specified in milliseconds.
*/
SetTimer (Hwnd, (UINT)Hwnd, interval, (TIMERPROC)TimeOutProc);
#else /* UNIX */
/* Get the Xt based information */
GRget (V_X_APPLIC_CONTEXT, &app_context, V_END_OF_LIST);
/* Post a timeout for dynamic updates
| The timeout procedure will update the dynamics of
| all screens which have been opened. The procedure is invoked
| whenever the specified time interval elapses. The interval is
| specified in milliseconds.
*/
XtAppAddTimeOut (app_context, interval,
(XtTimerCallbackProc) time_out_proc, NULL);
#endif /* WINNT */
#endif /* DV_USE_TIMER */
/* Control Loop */
QuitStatus = (DV_BOOL) NO;
while (QuitStatus == NO)
{
#ifdef DV_USE_TIMER
/* Gather and Process User Inputs
| Note: since we posted a time-out, the event
| handler will call our function to handle
| the updating of dynamic objects.
*/
location = VOloWinEventPoll (V_WAIT);
#else /* Not DV_USE_TIMER */
/* Update the Display */
HandleDynamics();
/* Get the Event */
location = VOloWinEventPoll( V_NO_WAIT );
#endif /* DV_USE_TIMER */
if (location)
(VOID) VUerHandleLocEvent (location);
}
/* Termination and Clean Up */
TermDisplays (); /* found in mfg_dsp.c */
TermData (); /* found in mfg_data.c */
(VOID) TTerminate (); /* DataViews Termination */
exit( EXIT_OK );
return 1;
}
#ifdef DV_USE_TIMER
#ifdef WINNT
/*ARGSUSED*/
LOCAL VOID CALLBACK
TimeOutProc (hwnd, uMsg, idEvent, dwTime)
HWND hwnd;
UINT uMsg;
UINT idEvent;
DWORD dwTime;
{
updating++;
if ( updating == 1)
HandleDynamics ();
updating--;
}
#else /* UNIX */
LOCAL void
time_out_proc (args, interval_id)
ADDRESS args;
XtIntervalId *interval_id;
{
HandleDynamics ();
XtAppAddTimeOut (app_context, interval,
(XtTimerCallbackProc) time_out_proc, NULL);
}
#endif /* UNIX */
#endif /* DV_USE_TIMER */